package cn.ld.module.system.dal.mapper.oauth2;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageInVO;
import cn.ld.module.system.dal.entity.oauth2.OAuth2ClientEntity;
import org.apache.ibatis.annotations.Mapper;


/**
 * OAuth2 客户端 Mapper
 *
 * @author 蓝盾
 */
@Mapper
public interface OAuth2ClientMapper extends BaseMapperX<OAuth2ClientEntity> {

    default PageResult<OAuth2ClientEntity> selectPage(OAuth2ClientPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<OAuth2ClientEntity>()
                .likeIfPresent(OAuth2ClientEntity::getName, inVO.getName())
                .eqIfPresent(OAuth2ClientEntity::getStatus, inVO.getStatus())
                .orderByDesc(OAuth2ClientEntity::getId));
    }

    default OAuth2ClientEntity selectByClientId(String clientId) {
        return selectOne(OAuth2ClientEntity::getClientId, clientId);
    }

}
